//创建下拉小仓库
import { defineStore } from 'pinia';
//引入请求的接口
import { reqC1, reqC2, reqC3 } from '@/api/product/attr/index';
let useCategoryStore = defineStore('category', {
	state: (): any => ({
		//创建一级分类的仓库
		c1Arr: [],
		//一级分类的id
		c1Id: '',
		//创建二级分类的仓库
		c2Arr: [],
		//二级分类的id
		c2Id: '',
		//创建三级分类的仓库
		c3Arr: [],
		//三级类的id
		c3Id: '',
	}),
	actions: {
		//获取一级分类的小仓库
		async getC1() {
			let result = await reqC1();
			// console.log('一级分类', result);
			this.c1Arr = result;
		},
		//获取二级分类的小仓库
		async getC2() {
			let result = await reqC2(this.c1Id);
			// console.log('二级分类', result);
			this.c2Arr = result;
		},
		//获取三级分类的小仓库
		async getC3() {
			let result = await reqC3(this.c2Id);
			// console.log('三级分类', result);
			this.c3Arr = result;
		},
	},
});
//默认暴露
export default useCategoryStore;
